package practice.tree.four;

import lombok.Data;
import utils.printer.BinaryTreeInfo;

/**
 * @Description:
 * @Author Ammar
 * @Create 2023/8/21 19:51
 */
@Data
public class BinaryTree implements BinaryTreeInfo {

    public TreeNode root;

    public int size;

    public void add(Integer val) {

    }

    protected TreeNode createTreeNode(Integer val, TreeNode parent) {
        return new TreeNode(val, parent);
    }

    protected void elementNotNull(Integer val) {
        if (val == null) throw new RuntimeException("element should not be null");
    }

    @Override
    public Object root() {
        return root;
    }

    @Override
    public Object left(Object node) {
        return ((TreeNode) node).left;
    }

    @Override
    public Object right(Object node) {
        return ((TreeNode) node).right;
    }

    @Override
    public Object string(Object node) {
        return node.toString();
    }
}
